#!/usr/bin/python2.5
class Table:############# This piece of code doesn't work anymore ################

    def __init__(self,num_lines,num_rows):
        self.board = []
        for l in range(num_lines):
            rows = []
            for r in range(num_rows):
                rows.append(None)
            self.board.append(rows)
    
    def get(self,line,row):
        return self.board[line][row]
    
    def put(self,piece,line,row):
        self.board[line][row] = piece
    
    def is_clean(self,line,row):
        return self.get(line,row) == None
    
    def clear(self,line,row):
        self.put(None,line,row)

class Water:
    pass

class Piece:

    def __init__(self,name):
        self.name = name

    def __str__(self):
        return self.name
    
    def move(self, line, row):
        
        

class CombatListener:

    def piece_added(self,piece,line,row):
        pass
        
class TextCombatListener(CombatListener):

    def piece_added(self,piece,line,row):
        print 'Piece added: %s (%s,%s)' % (piece,line,row)

class CombatGame:

    POPULATING = 0

    def __init__(self):
        self.table = Table(10,10)
        self.status = CombatGame.POPULATING
        self.listeners = []
        self.add_listener( TextCombatListener() )
    
    def start(self):
        self.opitions = ['All the posible pieces with your numbers of repetition']
        
    def add_piece(self,piece,line,row):
        if line or row > 9:
            return 'Position out of the table', False
        if not isinstance(self.table.get(line,row),Water):
            self.table.put(piece,line,row)
            for listener in self.listeners:
                  listener.piece_added(piece,line,row)
            try:
                start.opitions.remove(piece)
            except:
                return "There isn't anymore this piece to chosse"
    
    def add_listener(self,listener):
        self.listeners.append(listener)

game = CombatGame()
gen = Piece('General')
game.add_piece(gen,0,0)
print game.table.get(0,0)
game.table.put(gen,0,1)
for i in game.table.board:
    print i